﻿using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ProdControls;

namespace ProdControlsTests {
    [TestClass]


    public class ProdButtonTests {

        [ClassInitialize]
        public static void Setup(TestContext context){
            //Start the Winforms Application
            Process.Start("WindowsFormsApplication.exe");
            Process.Start("WpfFormTestWindow.exe");

        }

        [ClassCleanup]
        public static void TearDown() {
            foreach (Process _process in Process.GetProcessesByName("WindowsFormsApplication")) {
                _process.Kill();
            }

            foreach (Process _process in Process.GetProcessesByName("WpfFormTestWindow")) {
                _process.Kill();
            }
        }

        [TestMethod]
        public void ButtonClickTestWinForm() {
            
            ProdWindow _win = new ProdWindow("Form1");
            ProdButton _button = new ProdButton(_win,"button1");
            _button.Invoke();
            
            ProdWindow _popup = new ProdWindow("Test");
            ProdButton _popupOk = new ProdButton(_popup,"Ok");
            Assert.IsNotNull(_popupOk);
           _popupOk.Invoke();
        }

        [TestMethod]
        public void ButtonClickTestWpf() {

            ProdWindow _win = new ProdWindow("Main");
            ProdButton _button = new ProdButton(_win, "button");
            _button.Invoke();

            ProdWindow _popup = new ProdWindow("Wpf Button");
            ProdButton _popupOk = new ProdButton(_popup, "Ok");
            Assert.IsNotNull(_popup);
            _popupOk.Invoke();
        }

        [TestMethod]
        public void ButtonGetTextWinForm() {

            ProdWindow _win = new ProdWindow("Form1");
            ProdButton _button = new ProdButton(_win, "button1");
            Assert.AreEqual("button1",_button.Text);
            
        }

        [TestMethod]
        public void ButtonGetTextWpf() {

            ProdWindow _win = new ProdWindow("MainWindow");
            ProdButton _button = new ProdButton(_win, "button");
            Assert.AreEqual("Button",_button.Text );

        }
    }
}
